﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SPMS.Log.Core;
using SPMS.Commons.Configuration;
using SPMS.Log.Configuration;

namespace SPMS.Log.Repository
{
    /// <summary>
    /// 可配置日志存储器接口
    /// </summary>
    /// <remarks>定义了可配置日志存储器接口</remarks>
    /// <history>
    /// [zanezeng]               2009/10/14 9:39    创建
    /// </history>
    public interface IConfigurableLoggingRepository : ILoggingRepository
    {
        #region ---Property

        /// <summary>
        /// 获得或者设置默认日志记录器的名称
        /// </summary>
        /// <value>默认日志记录器的名称</value>
        /// <remarks></remarks>
        /// <history>
        /// [zanezeng]               2009/10/15 11:43    创建
        /// </history>
        string DefaultLoggerName
        {
            get;
            set;
        }

        #endregion

        #region ---Method

        /// <summary>
        /// 使用给定的配置信息配置当前日志存储器
        /// </summary>
        /// <param name="configuration">用来配置日志存储器的配置信息</param>
        /// <param name="handlerFactory">配置节点处理器工厂</param>
        /// <param name="variableProvider">扩展变量提供者</param>
        /// <remarks></remarks>
        /// <exception cref="ObjectDisposedException">当前日志存储器已经被关闭</exception>
        /// <exception cref="ArgumentNullException"><paramref name="configuration"/>为<c>null</c>引用。</exception>
        /// <exception cref="ArgumentNullException"><paramref name="handlerFactory"/>为<c>null</c>引用。</exception>
        /// <exception cref="ArgumentNullException"><paramref name="variableProvider"/>为<c>null</c>引用。</exception>
        /// <history>
        /// [zanezeng]               2009/10/14 9:44    创建
        /// </history>
        void Configure(IConfiguration configuration,
                        IConfigurationNodeHandlerFactory<ParseContext> handlerFactory,
                        IExtendedVariableProvider variableProvider);

        /// <summary>
        /// 将给定的日志追加器注册当前日志存储器中
        /// </summary>
        /// <param name="appender">要注册的日志追加器</param>
        /// <remarks>如果同名的日志追加器已经存在，则替换已经存在的日志追加器。</remarks>
        /// <exception cref="ArgumentNullException"><paramref name="appender"/>为<c>null</c>引用。</exception>
        /// <exception cref="ArgumentException"><paramref name="appender"/>的<see cref="ILogAppender.Name"/>为空字符串或者为<c>null</c>引用。</exception>
        /// <exception cref="ObjectDisposedException">当前日志存储器已经被关闭。</exception>
        /// <history>
        /// [zanezeng]               2009/10/15 9:33    创建
        /// </history>
        void RegisterAppender(ILogAppender appender);

        /// <summary>
        /// 从当前的日志存储器中注销给定的日志追加器
        /// </summary>
        /// <param name="appender">要注销的日志追加器</param>
        /// <returns>
        /// 	<c>true</c>：给定的日志追加器注销成功<br/>
        /// 	<c>false</c>：给定的日志追加器注销失败
        /// </returns>
        /// <exception cref="ArgumentNullException"><paramref name="appender"/>为<c>null</c>引用。</exception>
        /// <exception cref="ArgumentException"><paramref name="appender"/>的<see cref="ILogAppender.Name"/>为空字符串或者为<c>null</c>引用。</exception>
        /// <exception cref="ObjectDisposedException">当前日志存储器已经被关闭</exception>
        /// <remarks>注意：名称不区分大小写</remarks>
        /// <history>
        /// [zanezeng]               2009/10/15 9:40    创建
        /// </history>
        bool UnregisterAppender(ILogAppender appender);

        /// <summary>
        /// 从当前的日志存储器中注销给定名称的日志追加器
        /// </summary>
        /// <param name="name">要注销日志追加器的注册名称</param>
        /// <returns>
        /// 被注销的日志追加器实例，如果给定名称的日志追加器不存在，则返回<c>null</c>引用。
        /// </returns>
        /// <exception cref="ArgumentNullException"><paramref name="name"/>为空字符串或者为<c>null</c>引用。</exception>
        /// <exception cref="ObjectDisposedException">当前日志存储器已经被关闭</exception>
        /// <remarks></remarks>
        /// <history>
        /// [zanezeng]               2009/10/15 9:44    创建
        /// </history>
        ILogAppender UnregisterAppender(string name);

        /// <summary>
        /// 注册日志记录器
        /// </summary>
        /// <param name="name">要注册的日志记录器的名称</param>
        /// <param name="level">日志记录器允许输出的最低日志级别，如果为NULL，则默认为日志存储器的默认日志级别</param>
        /// <param name="isDefault">是否设置为默认日志记录器</param>
        /// <param name="referAppenders">要注册的日志记录器引用的日志追加器</param>
        /// <remarks></remarks>
        /// <exception cref="ObjectDisposedException">当前日志存储器已经被关闭</exception>
        /// <exception cref="ArgumentNullException"><paramref name="name"/>为<c>null</c>引用或者为空字符串</exception>
        /// <exception cref="ArgumentException"><paramref name="referAppenders"/>引用不存在的日志追加器</exception>
        /// <history>
        /// [zanezeng]               2009/10/15 9:49    创建
        /// </history>
        void RegisterLogger(string name, Level level, bool isDefault, params string[] referAppenders);

        /// <summary>
        /// 注销给定名称的日志记录器
        /// </summary>
        /// <param name="name">要注销的日志记录器的名称</param>
        /// <returns>
        /// 	<c>true</c>：给定名称的日志记录器注销成功<br/>
        /// 	<c>false</c>：给定名称的日志记录器不存在
        /// </returns>
        /// <exception cref="ArgumentNullException"><paramref name="name"/>为空字符串或者为<c>null</c>引用。</exception>
        /// <exception cref="ObjectDisposedException">当前日志存储器已经被关闭</exception>
        /// <remarks></remarks>
        /// <history>
        /// [zanezeng]               2009/10/15 9:50    创建
        /// </history>
        bool UnregisterLogger(string name);

        /// <summary>
        /// 设置当前日志存储器的默认日志级别
        /// </summary>
        /// <param name="level">默认的日志级别</param>
        /// <remarks></remarks>
        /// <history>
        /// [zanezeng]               2009/10/16 9:51    创建
        /// </history>
        void SetDefaultLevel(Level level);

        /// <summary>
        /// 设置当前日志存储器的名称
        /// </summary>
        /// <param name="name">日志存储器的名称</param>
        /// <remarks></remarks>
        /// <history>
        /// [zanezeng]               2009/10/16 9:58    创建
        /// </history>
        void SetName(string name);

        #endregion
    }
}
